﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.BaseInformation;
using TyMES.Model;

namespace TyMES.ViewModel.BaseInformation.LMESBadCodeTemplateVMs
{
    public partial class LMESBadCodeTemplateListVM : BasePagedListVM<LMESBadCodeTemplate_View, LMESBadCodeTemplateSearcher>
    {
        
        protected override IEnumerable<IGridColumn<LMESBadCodeTemplate_View>> InitGridHeader()
        {
            return new List<GridColumn<LMESBadCodeTemplate_View>>{
                
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_LMESBadCode).SetTitle(@Localizer["Page.产线不良信息编号"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_LMESBadDescription).SetTitle(@Localizer["Page.产线不良信息描述"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_OperationCode).SetTitle(@Localizer["Page.工序信息"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_BadCode).SetTitle(@Localizer["Page.不良编码"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_BadName).SetTitle(@Localizer["Page.不良名称"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_BadTypeCode).SetTitle(@Localizer["Page.不良类型编码"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_BadTypeName).SetTitle(@Localizer["Page.不良类型名称"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_AddTime).SetTitle(@Localizer["Page.添加时间"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_DataStatus).SetTitle(@Localizer["Page.数据状态"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_EditTime).SetTitle(@Localizer["Page.编辑时间"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_EnableStatus).SetTitle(@Localizer["Page.启用状态"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_FactoryCode).SetTitle(@Localizer["Page.工厂编码"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_Field1).SetTitle(@Localizer["Page.预留域1"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_Field2).SetTitle(@Localizer["Page.预留域2"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_Field3).SetTitle(@Localizer["Page.预留域3"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_Field4).SetTitle(@Localizer["Page.预留域4"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_Field5).SetTitle(@Localizer["Page.预留域5"].Value),
                this.MakeGridHeader(x => x.LMESBadCodeTemplate_IsValid).SetTitle(@Localizer["_Admin.IsValid"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<LMESBadCodeTemplate_View> GetSearchQuery()
        {
            var query = DC.Set<LMESBadCodeTemplate>()
                
                .CheckContain(Searcher.LMESBadCode, x=>x.LMESBadCode)
                .CheckContain(Searcher.LMESBadDescription, x=>x.LMESBadDescription)
                .CheckContain(Searcher.OperationCode, x=>x.OperationCode)
                .CheckContain(Searcher.BadCode, x=>x.BadCode)
                .CheckContain(Searcher.BadName, x=>x.BadName)
                .CheckContain(Searcher.BadTypeCode, x=>x.BadTypeCode)
                .CheckContain(Searcher.BadTypeName, x=>x.BadTypeName)
                .CheckBetween(Searcher.AddTime?.GetStartTime(), Searcher.AddTime?.GetEndTime(), x => x.AddTime, includeMax: false)
                .CheckContain(Searcher.DataStatus, x=>x.DataStatus)
                .CheckBetween(Searcher.EditTime?.GetStartTime(), Searcher.EditTime?.GetEndTime(), x => x.EditTime, includeMax: false)
                .CheckContain(Searcher.EnableStatus, x=>x.EnableStatus)
                .CheckContain(Searcher.FactoryCode, x=>x.FactoryCode)
                .CheckContain(Searcher.Field1, x=>x.Field1)
                .CheckContain(Searcher.Field2, x=>x.Field2)
                .CheckContain(Searcher.Field3, x=>x.Field3)
                .CheckContain(Searcher.Field4, x=>x.Field4)
                .CheckContain(Searcher.Field5, x=>x.Field5)
                .Select(x => new LMESBadCodeTemplate_View
                {
				    ID = x.ID,
                    
                    LMESBadCodeTemplate_LMESBadCode = x.LMESBadCode,
                    LMESBadCodeTemplate_LMESBadDescription = x.LMESBadDescription,
                    LMESBadCodeTemplate_OperationCode = x.OperationCode,
                    LMESBadCodeTemplate_BadCode = x.BadCode,
                    LMESBadCodeTemplate_BadName = x.BadName,
                    LMESBadCodeTemplate_BadTypeCode = x.BadTypeCode,
                    LMESBadCodeTemplate_BadTypeName = x.BadTypeName,
                    LMESBadCodeTemplate_AddTime = x.AddTime,
                    LMESBadCodeTemplate_DataStatus = x.DataStatus,
                    LMESBadCodeTemplate_EditTime = x.EditTime,
                    LMESBadCodeTemplate_EnableStatus = x.EnableStatus,
                    LMESBadCodeTemplate_FactoryCode = x.FactoryCode,
                    LMESBadCodeTemplate_Field1 = x.Field1,
                    LMESBadCodeTemplate_Field2 = x.Field2,
                    LMESBadCodeTemplate_Field3 = x.Field3,
                    LMESBadCodeTemplate_Field4 = x.Field4,
                    LMESBadCodeTemplate_Field5 = x.Field5,
                    LMESBadCodeTemplate_IsValid = x.IsValid,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class LMESBadCodeTemplate_View: LMESBadCodeTemplate
    {
        
        public string LMESBadCodeTemplate_LMESBadCode { get; set; }
        public string LMESBadCodeTemplate_LMESBadDescription { get; set; }
        public string LMESBadCodeTemplate_OperationCode { get; set; }
        public string LMESBadCodeTemplate_BadCode { get; set; }
        public string LMESBadCodeTemplate_BadName { get; set; }
        public string LMESBadCodeTemplate_BadTypeCode { get; set; }
        public string LMESBadCodeTemplate_BadTypeName { get; set; }
        public DateTime? LMESBadCodeTemplate_AddTime { get; set; }
        public string LMESBadCodeTemplate_DataStatus { get; set; }
        public DateTime? LMESBadCodeTemplate_EditTime { get; set; }
        public string LMESBadCodeTemplate_EnableStatus { get; set; }
        public string LMESBadCodeTemplate_FactoryCode { get; set; }
        public string LMESBadCodeTemplate_Field1 { get; set; }
        public string LMESBadCodeTemplate_Field2 { get; set; }
        public string LMESBadCodeTemplate_Field3 { get; set; }
        public string LMESBadCodeTemplate_Field4 { get; set; }
        public string LMESBadCodeTemplate_Field5 { get; set; }
        public bool LMESBadCodeTemplate_IsValid { get; set; }

    }

}